package com.weds.edpf.core.web;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import javax.validation.Valid;

import com.weds.core.base.BaseController;
import com.weds.core.annotation.Logs;
import com.weds.core.resp.JsonResult;
import com.weds.core.base.BaseCommPager;
import com.weds.core.base.BasePageSearch;


import com.weds.edpf.core.entity.NWtRegEntity;
import com.weds.edpf.core.service.NWtRegService;

/**
 * @Author wangjianqiang
 * @Description NWtReg管理
 * @Date 2020-06-16
 */
@RestController
@RequestMapping(value = "/nWtReg")
@Api(value = "NWtReg管理", description = "NWtReg管理")
public class NWtRegController extends BaseController {
    @Autowired
    private NWtRegService nWtRegService;


    private Logger log = LogManager.getLogger();

    @Logs
    @ApiOperation(value = "新增NWtReg信息", notes = "新增NWtReg信息")
    @RequestMapping(value = "/insert", method = RequestMethod.PUT)
    public JsonResult<Object> insert(@RequestBody @Valid NWtRegEntity record) {
        nWtRegService.insertSelective(record);
        return succMsg();
    }

    @Logs
    @ApiOperation(value = "查询NWtReg清单", notes = "查询NWtReg清单")
    @RequestMapping(value = "/selectListPageByEntity", method = RequestMethod.POST)
    public JsonResult<BaseCommPager<NWtRegEntity>> selectListPageByEntity(@RequestBody BasePageSearch<NWtRegEntity> record) {
        setPageHelper(record);
        NWtRegEntity entity = record.getSearch();
        if (entity == null) {
            entity = new NWtRegEntity();
        }
        List<NWtRegEntity> list = nWtRegService.selectListByEntity(entity);
        return succMsgData(new BaseCommPager<NWtRegEntity>(list));
    }

    @Logs
    @ApiOperation(value = "查询NWtReg列表", notes = "查询NWtReg列表")
    @RequestMapping(value = "/selectListByEntity", method = RequestMethod.POST)
    public JsonResult<List<NWtRegEntity>> selectListByEntity(@RequestBody NWtRegEntity record) {
        List<NWtRegEntity> list = nWtRegService.selectListByEntity(record);
        return succMsgData(list);
    }


    @Logs
    @ApiOperation(value = "批量新增NWtReg信息", notes = "批量新增NWtReg信息")
    @RequestMapping(value = "/insertBatch", method = RequestMethod.PUT)
    public JsonResult<Object> insertBatch(@RequestParam String data) {
        List<NWtRegEntity> list = JSONObject.parseArray(data, NWtRegEntity.class);
        nWtRegService.insertBatch(list);
        return succMsg();
    }
}